<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/27/027
 * Time: 10:05
 */

namespace app\Lib\Model\Role;


use app\Lib\Model\DbModel\RoleUser;
use app\Lib\Model\User\User;

class GetRoleUser
{
    /**
     * 获取所有设计部门人员
     * @return array
     */
    public function getDeign(){
        $table = new \app\Lib\Model\DbModel\Role();
        $roleId = $table
            ->where([$table->_role_alias=>'designer'])
            ->whereOr([$table->_role_alias=>'designDirector'])
            ->column($table->_id);
        $model = new RoleUser();
        $userId =  $model->where([$model->_role_id=>['in',$roleId]])->column($model->_uid);
        $userArray = [];
        foreach ($userId as $v){
            $user = new User($v);
            $userArray[$user->getUid()] = $user->getNickName();
        }
        return  $userArray;
    }

    /**
     * 获取工程部经理
     */
    public function getEngineeringManager(){
        $table = new \app\Lib\Model\DbModel\Role();
        $roleId = $table
            ->where([$table->_role_alias=>'engineeringDepartmentManager'])
            ->value($table->_id);
        $model = new RoleUser();
        $userId =  $model->where([$model->_role_id=>$roleId])->value($model->_uid);
        return  $userId;
    }

    /**
     * 获取工程部监工
     */
    public function getSupervisor(){
        $table = new \app\Lib\Model\DbModel\Role();
        $roleId = $table
            ->where([$table->_role_alias=>'engineeringDepartmentSupervision'])
            ->value($table->_id);
        $model = new RoleUser();
        $userId =  $model->where([$model->_role_id=>$roleId])->column($model->_uid);
        $userArray = [];
        foreach ($userId as $v){
            $user = new User($v);
            $userArray[$user->getUid()] = $user->getNickName();
        }
        return  $userArray;
//        return  $userId;
    }
    /**
     * 获取设计总监
     */
    public function getDeignDirector(){
        $table = new \app\Lib\Model\DbModel\Role();
        $roleId = $table
            ->where([$table->_role_alias=>'designDirector'])
            ->value($table->_id);
        $model = new RoleUser();
        $userId =  $model->where([$model->_role_id=>$roleId])->value($model->_uid);
        return  $userId;
    }

}